package com.xiaozhuai.controller;

import com.alibaba.fastjson.JSON;
import com.fasterxml.jackson.annotation.JsonIgnoreType;
import netscape.javascript.JSObject;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.HashMap;
import java.util.Map;

@RestController
public class IpController {

    @RequestMapping(value = "/ip", produces = "application/json;charset=UTF-8")
    public String getIp(HttpServletRequest res){
        String remoteAddress = res.getRemoteAddr();
        Map<String,String> responseMap = new HashMap<>();
        responseMap.put("msg","success");
        responseMap.put("code","200");
        responseMap.put("ip",remoteAddress);
        String str = JSON.toJSONString(responseMap);
        return str;
    }
}
